/********************************************************************
	created:	2012/02/22
	created:	22:2:2012   21:53
	file base:	ITerrain
	file ext:	h
	author:		Baesky
	
	purpose:	interface support
*********************************************************************/
#pragma once
class ITerrain;

//although I use Ogre now, but don't want my terrain class too couple with Ogre.
class ITexMgr
{
public:
	virtual bool LoadImg(const char* fileName)						= 0;
	virtual bool SaveImg(const char* fileName)						= 0;
	virtual void GetColorValueAt(int iX, int iZ, float fHeight, int texIdx, float& r, float& g, float& b, float& a) = 0;
	virtual int GetImgCnt()											= 0;
	virtual void* GenerateTexture(int iResolution, ITerrain* parent)= 0;
};

//every terrain class need derived from this interface
class ITerrain
{
public:
	//init terrain rendering data
	virtual bool InitTerrainData(const char* fileName, int terrainSize)	= 0;
	//uninit terrain redering data
	virtual bool ClearTerrainData()										= 0;
	//save the procedural tex(if support) to disk
	virtual bool SaveTex(const char* fileName)							= 0;
	//save the terrain rendering data to dist
	virtual bool SaveData(const char* fileName)							= 0;
	//set a value for special point exist in terrain range
	virtual void SetHeight(int x, int z, float val)						= 0;
	//get the value at special point
	virtual float GetRawHeight(int x, int z)							= 0;
	//get the scaled value at special point
	virtual float GetScaleHeight(int x, int z)							= 0;

	//get the interpolated val of special point
	virtual float InterpolateHeight(int ix, int iz, float fH2tRadio)    = 0;


	//set the scale radio
	inline void SetHeightScale(float scale){m_fScale = scale;}
	//get the scale radio
	inline float GetHeightScale(){ return m_fScale;}
	//get terrain size
	inline int GetSize(){return m_iSize;}
public:
	ITexMgr* m_texMgr;
protected:
	float m_fScale;
	int m_iSize;
};

